﻿/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2012-4-25
/// Purpose: 		成员身份服务的WCF实现版本的客户端类
/// ****************************************************************************
/// Modify By		Date			Remark
/// Robin           2012-6-4        增加AddUserToApp接口实现
/// ****************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Configuration;
using System.ServiceModel.Description;

namespace RB.Web.Security.Wcf
{
    /// <summary>
    /// 成员身份服务的WCF实现版本的客户端类
    /// </summary>
    public class WcfMembershipService : ClientBase<IMembershipService>, IMembershipService
    {
        public WcfMembershipService()
            : base(new ServiceEndpoint(ContractDescription.GetContract(typeof(IMembershipService)), 
                new BasicHttpBinding(),
                new EndpointAddress(WcfSecurityConfigSection.Current.GetServiceAddress("MembershipService.svc"))))
        {
        }

        public bool CreateUser(UserAccount userAccount)
        {
            return base.Channel.CreateUser(userAccount);
        }

        public bool DeleteUser(string username, bool deleteAllRelatedData, string deleteBy)
        {
            return base.Channel.DeleteUser(username, deleteAllRelatedData, deleteBy);
        }

        public IList<UserAccount> FindUsersByEmail(string emailToMatch)
        {
            return base.Channel.FindUsersByEmail(emailToMatch);
        }

        public IList<UserAccount> FindUsersByName(string usernameToMatch)
        {
            return base.Channel.FindUsersByName(usernameToMatch);
        }

        public IList<UserAccount> GetAllUsers()
        {
            return base.Channel.GetAllUsers();
        }

        public int GetNumberOfUsersOnline(int userIsOnlineTimeWindow)
        {
            return base.Channel.GetNumberOfUsersOnline(userIsOnlineTimeWindow);
        }

        public UserAccount GetUserByName(string username, bool userIsOnline)
        {
            return base.Channel.GetUserByName(username, userIsOnline);
        }

        public UserAccount GetUserByKey(Guid providerUserKey, bool userIsOnline)
        {
            return base.Channel.GetUserByKey(providerUserKey, userIsOnline);
        }

        public UserAccount GetUserByEmail(string email)
        {
            return base.Channel.GetUserByEmail(email);
        }

        public bool UnlockUser(string userName)
        {
            return base.Channel.UnlockUser(userName);
        }

        public void UpdateUser(UserAccount user)
        {
            base.Channel.UpdateUser(user);
        }

        public bool LoginUser(string username, string password, int maxInvalidPasswordAttempts, int passwordAttemptWindow)
        {
            return base.Channel.LoginUser(username, password, maxInvalidPasswordAttempts, passwordAttemptWindow);
        }

        public bool ValidateUser(string username, string password)
        {
            return base.Channel.ValidateUser(username, password);
        }

        public bool ChangePassword(string username, string newPassword, string changeBy)
        {
            return base.Channel.ChangePassword(username, newPassword, changeBy);
        }

        public bool ChangePasswordQuestionAndAnswer(string username, string newPasswordQuestion, string newPasswordAnswer, string changeBy)
        {
            return base.Channel.ChangePasswordQuestionAndAnswer(username, newPasswordQuestion, newPasswordAnswer, changeBy);
        }

        public string GetPassword(string username)
        {
            return base.Channel.GetPassword(username);
        }

        public bool ValidatePasswordAnswer(string username, string answer)
        {
            return base.Channel.ValidatePasswordAnswer(username, answer);
        }

        public void AddUserToApp(Guid userId, string appCode, string createBy)
        {
            base.Channel.AddUserToApp(userId, appCode, createBy);
        }
    }
}
